<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>添加应用</title>
#include("/sysapp/global_css.html")
<link rel="stylesheet" href="/static/img/ui/sys.css">
</head>

<body>
<ul class="nav nav-tabs" style="margin:5px 12px">
	#foreach($c in $category){
		<li class="dropdown"><a href="#category_{$c.tbid}" data-toggle="tab">$c.name</a></li>
	#end
</ul>
<div class="tab-content">
	$!content
</div>
<input type="hidden" id="value_1">
#include("/sysapp/global_js.html")
<script>
$(function(){
	$('.nav-tabs a:first').tab('show');
	if($.dialog.data('appsid') != ''){
		$('#value_1').val($.dialog.data('appsid'));
		var appsid = $.dialog.data('appsid').split(',');
		$('.app').each(function(){
			for(var i=0; i<appsid.length; i++){
				if(appsid[i] == $(this).attr('appid')){
					$(this).addClass('act');
					break;
				}
			}
		});
	}
	$('.app').click(function(){
		if($(this).hasClass('act')){
			var appsid = $('#value_1').val().split(',');
			var newappsid = [];
			for(var i=0, j=0; i<appsid.length; i++){
				if(appsid[i] != $(this).attr('appid')){
					newappsid[j] = appsid[i];
					j++;
				}
			}
			$('#value_1').val(newappsid.join(','));
			$(this).removeClass('act');
		}else{
			if($('#value_1').val() != ''){
				var appsid = $('#value_1').val().split(',');
				appsid[appsid.length] = $(this).attr('appid');
				$('#value_1').val(appsid.join(','));
			}else{
				$('#value_1').val($(this).attr('appid'));
			}
			$(this).addClass('act');
		}
		$.dialog.data('appsid', $('#value_1').val());
	});
});
</script>
</body>
</html>